package com.tracesystem.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tracesystem.commons.Result;
import com.tracesystem.controller.Info.AllPriorityPageInfo;
import com.tracesystem.controller.Info.AllTypePageInfo;
import com.tracesystem.controller.form.*;
import com.tracesystem.dao.IssuePriorityDao;
import com.tracesystem.model.IssuePriority;
import com.tracesystem.model.IssueType;
import com.tracesystem.service.IssuePriorityService;
import com.tracesystem.util.WoniuCopyUtil;
import com.tracesystem.util.exception.IssuePriorityException;
import com.tracesystem.util.exception.IssueTypeException;
import com.tracesystem.util.exception.code.IssuePriorityExceptionCode;
import com.tracesystem.util.exception.code.IssueTypeExceptionCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Kevin Martin
 * @since 2022-03-23
 */
@RestController
@RequestMapping("/issuePriority")
@Api(tags = "缺陷优先级操作相关接口 如更新、新增、删除、查询")
public class IssuePriorityController {

    /**
     * 缺陷优先级业务层对象
     */
    @Resource
    private IssuePriorityService issuePriorityService;

    /**
     * 缺陷优先级业务层对象
     */
    @Resource
    private IssuePriorityDao issuePriorityDao;

    /**
     * 添加缺陷优先级分类项
     * @param addPriorityForm
     * @return
     */
    @ApiOperation("新增缺陷优先级分类")
    @PostMapping("/addPriority")
    public Result<?> addPriority(@Valid @RequestBody AddPriorityForm addPriorityForm){
        return issuePriorityService.insertPriority(addPriorityForm);
    }

    /**
     * 删除缺陷优先级分类项
     * @param removePriorityForm
     * @return
     */
    @ApiOperation("删除缺陷优先级分类")
    @PostMapping("/removePriority")
    public Result<?> removePriority(@RequestBody RemovePriorityForm removePriorityForm){
        return issuePriorityService.delectPriority(removePriorityForm);
    }

    /**
     * 批量删除缺陷优先级
     * @param removePriorityListForm
     * @return
     */
    @ApiOperation("批量删除缺陷优先级")
    @PostMapping("/removePriorityList")
    public Result<?> removePriorityList(@RequestBody RemovePriorityListForm removePriorityListForm){
        return issuePriorityService.delectPriorityList(removePriorityListForm);
    }

    /**
     * 修改缺陷优先级
     * @param renewalPriorityDescForm
     * @return
     */
    @ApiOperation("修改缺陷优先级")
    @PostMapping("/renewalTypeDesc")
    public Result<?> renewalPriorityDesc(@RequestBody RenewalPriorityDescForm renewalPriorityDescForm){
        return issuePriorityService.updatePriorityDesc(renewalPriorityDescForm);
    }

    /**
     * 修改缺陷缺陷优先级状态
     * @param renewalPriorityModuleStateForm
     * @return
     */
    @ApiOperation("修改缺陷优先级状态：禁用/启用")
    @PostMapping("/renewalPriorityModuleState")
    public Result<?> renewalPriorityModuleState(@RequestBody RenewalPriorityModuleStateForm renewalPriorityModuleStateForm){
        return issuePriorityService.updateModuleState(renewalPriorityModuleStateForm);
    }

    /**
     * 模糊查询缺陷优先级分类
     * @param likePriorityListForm
     * @return
     */
    @ApiOperation("模糊查询缺陷优先级分类")
    @PostMapping("/likePriorityList")
    public Result<AllPriorityPageInfo> likePriorityList(@RequestBody LikePriorityListForm likePriorityListForm){
        return issuePriorityService.findPagePriorityListByPriorityDesc(likePriorityListForm);
    }

    /**
     * 查询所有缺陷优先级分类
     * @param findAllPriorityListForm
     * @return
     */
    @ApiOperation("查询所有缺陷优先级分类")
    @PostMapping("/findAllPriorityList")
    public Result<AllPriorityPageInfo> findAllPriorityList(@RequestBody FindAllPriorityListForm findAllPriorityListForm){
        return issuePriorityService.getAllPriorityList(findAllPriorityListForm);
    }

}

